import { Random as _Random, mock } from 'mockjs'
import respFormatter from '../mock/index'
/**
 * 参考官网：https://github.com/nuysoft/Mock/wiki/Getting-Started
 */
const basePath = '/api/mock/'

// 配置 Mock 路径
// require.config({
//   paths: {
//     mock: 'http://localhost:8888/'
//   }
// })

// 获取 mock.Random 对象
const Random = _Random
const answerPool = 'ABCD'
const questionList = function() {
  let tempListForType1 = []
  for (let index = 0; index < 18; index++) {
    let tempObj = {
      questionNo: Random.integer(1, 500),
      question: Random.ctitle(10, 30),
      options: {
        A: Random.csentence(10, 20),
        B: Random.csentence(10, 20),
        C: Random.csentence(10, 20),
        D: Random.csentence(10, 20)
      },
      answer: Random.character(answerPool),
      questionType: 1,
      submitDept: Random.ctitle(3, 8),
      questionNote: Random.cparagraph(15, 100),
      questionScore: 5
    }
    tempListForType1.push(tempObj)
  }
  let tempListForType2 = []
  for (let index = 0; index < 2; index++) {
    let tempObj = {
      questionNo: Random.integer(1, 500),
      question: Random.ctitle(10, 30),
      options: {
        A: Random.csentence(10, 20),
        B: Random.csentence(10, 20),
        C: Random.csentence(10, 20),
        D: Random.csentence(10, 20)
      },
      answer: Random.string(answerPool, 2),
      questionType: 2,
      submitDept: Random.ctitle(3, 8),
      questionNote: Random.cparagraph(15, 100),
      questionScore: 5
    }
    tempListForType2.push(tempObj)
  }
  respFormatter.bizContent = {
    questionBody: [
      {
        questionList: tempListForType1,
        questionType: '1'
      },
      {
        questionList: tempListForType2,
        questionType: '2'
      }
    ],
    questionCfg: '1:18:5;2:2:5',
    timeLimit: '3600'
  }
  return respFormatter
}
mock(basePath + 'getQuestionList', 'post', questionList)
// module.exports = questionList
